package com.ruoyi.orders.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.orders.domain.SmartParkingOrder;
import com.ruoyi.orders.service.ISmartParkingOrderService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 停车订单Controller
 * 
 * @author ruoyi
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/parkingOrder")
public class SmartParkingOrderController extends BaseController
{
    @Autowired
    private ISmartParkingOrderService smartParkingOrderService;

    /**
     * 查询停车订单列表
     */
    @RequiresPermissions("orders:parkingOrder:list")
    @GetMapping("/list")
    public TableDataInfo list(SmartParkingOrder smartParkingOrder)
    {
        startPage();
        List<SmartParkingOrder> list = smartParkingOrderService.selectSmartParkingOrderList(smartParkingOrder);
        return getDataTable(list);
    }

    /**
     * 导出停车订单列表
     */
    @RequiresPermissions("orders:parkingOrder:export")
    @Log(title = "停车订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmartParkingOrder smartParkingOrder)
    {
        List<SmartParkingOrder> list = smartParkingOrderService.selectSmartParkingOrderList(smartParkingOrder);
        ExcelUtil<SmartParkingOrder> util = new ExcelUtil<SmartParkingOrder>(SmartParkingOrder.class);
        util.exportExcel(response, list, "停车订单数据");
    }

    /**
     * 获取停车订单详细信息
     */
    @RequiresPermissions("orders:parkingOrder:query")
    @GetMapping(value = "/{scOrderId}")
    public AjaxResult getInfo(@PathVariable("scOrderId") Long scOrderId)
    {
        return success(smartParkingOrderService.selectSmartParkingOrderByScOrderId(scOrderId));
    }

    /**
     * 新增停车订单
     */
    @RequiresPermissions("orders:parkingOrder:add")
    @Log(title = "停车订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmartParkingOrder smartParkingOrder)
    {
        return toAjax(smartParkingOrderService.insertSmartParkingOrder(smartParkingOrder));
    }

    /**
     * 修改停车订单
     */
    @RequiresPermissions("orders:parkingOrder:edit")
    @Log(title = "停车订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmartParkingOrder smartParkingOrder)
    {
        return toAjax(smartParkingOrderService.updateSmartParkingOrder(smartParkingOrder));
    }

    /**
     * 删除停车订单
     */
    @RequiresPermissions("orders:parkingOrder:remove")
    @Log(title = "停车订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scOrderIds}")
    public AjaxResult remove(@PathVariable Long[] scOrderIds)
    {
        return toAjax(smartParkingOrderService.deleteSmartParkingOrderByScOrderIds(scOrderIds));
    }
}
